package com.pureut.production.controller;

import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.common.security.annotation.RequiresPermissions;
import com.pureut.production.domain.DegreasOutputDetail;
import com.pureut.production.domain.dto.DegreasOutputDetailDto;
import com.pureut.production.domain.dto.DegreasOutputDto;
import com.pureut.production.domain.vo.DegreasOutputDetailVo;
import com.pureut.production.domain.vo.DegreasOutputVo;
import com.pureut.production.domain.vo.UpdateByDegreasOutDetailVo;
import com.pureut.production.service.DegreasOutputDetailService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 脱脂产出明细控制层
 */
@RestController
@RequestMapping("/degreas_output_detail")
public class DegreasOutputDetailController extends BaseController {

    /**
     * 脱脂产出明细service
     */
    @Resource
    DegreasOutputDetailService degreasOutputDetailService;

    /**
     * 脱脂产出明细列表
     */
//    @RequiresPermissions("production:degreas:output:list")
    @GetMapping("/list")
    public TableDataInfo degreasOutputList(String degreasOrderNumber) {
        startPage();
        // 脱脂产出明细列表
        List<DegreasOutputDetailDto> list = degreasOutputDetailService.getList(degreasOrderNumber);
        return getDataTable(list);
    }

    /**
     * 明细详情
     */
    @RequiresPermissions("productionTube:produAdm:degrproduc:degparaorder:codeAgain")
    @GetMapping("/getView/{id}")
    public AjaxResult getView(@PathVariable("id") Long id) {
        return AjaxResult.success(degreasOutputDetailService.getView(id));
    }

    /**
     * 条码修正
     */
    @RequiresPermissions("productionTube:produAdm:degrproduc:degparaorder:codeRepair")
    @PostMapping("/codeCorrection")
    public AjaxResult codeCorrection(@RequestBody DegreasOutputDetailVo degreasOutputDetailVo) throws Exception {
        return AjaxResult.success(degreasOutputDetailService.codeCorrection(degreasOutputDetailVo));
    }

    /**
     * 修改明细检验状态，检验结果(品质审核时候调用)
     */
    @PostMapping("/updateByDegreasOutDetail")
    public AjaxResult updateByDegreasOutDetail(@RequestBody UpdateByDegreasOutDetailVo updateByDegreasOutDetailVo) {
        return toAjax(degreasOutputDetailService.updateByDegreasOutDetail(updateByDegreasOutDetailVo));
    }

    /**
     * 修改明细检验物料等级(品质处理时候调用)
     */
    @PostMapping("/updateByDegreasOutDetailQuality")
    public AjaxResult updateByDegreasOutDetailQuality(@RequestBody UpdateByDegreasOutDetailVo updateByDegreasOutDetailVo) {
        return toAjax(degreasOutputDetailService.updateByDegreasOutDetailQuality(updateByDegreasOutDetailVo));
    }

    /**
     * 根据物料号码查询脱脂产出明细详情
     * @param materialNumber
     * @return
     */
    @GetMapping("/selectMaterialNumberInfo")
    public AjaxResult selectMaterialNumberInfo(String materialNumber) {
        return AjaxResult.success(degreasOutputDetailService.selectMaterialNumberInfo(materialNumber));
    }

    /**
     * 查询脱脂产出明细数据
     */
    @GetMapping("/getDetailList")
    public AjaxResult getDegreasOrderDetailList(String degreasOrderNumber) {
        return AjaxResult.success(degreasOutputDetailService.getDetailList(degreasOrderNumber));
    }

    /**
     * 查询脱脂产出明细数据
     */
    @GetMapping("/selectDetailListMaterialNumber")
    public AjaxResult selectDetailListMaterialNumber(String materialNumber) {
        return AjaxResult.success(degreasOutputDetailService.selectDetailListMaterialNumber(materialNumber));
    }


}
